package com.sunwayworld.basemodule.business.pjreport.resource.impl;

import com.sunwayworld.basemodule.business.report.validators.LimsReportSubmitValidator;
import com.sunwayworld.framework.validator.data.annotation.ValidateDataWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.sunwayworld.basemodule.business.pjreport.resource.LimsPjReportResource;
import com.sunwayworld.basemodule.business.pjreport.service.LimsPjReportService;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import com.sunwayworld.framework.log.annotation.Log;
import com.sunwayworld.framework.log.annotation.LogModule;
import com.sunwayworld.framework.log.annotation.LogType;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@LogModule("普检检测报告")
@RestController
@GikamBean
public class LimsPjReportResourceImpl implements LimsPjReportResource {

    @Autowired
    private LimsPjReportService limsPjReportService;

    @Override
    public LimsPjReportService getService() {
        return limsPjReportService;
    }

    @Log(value = "新增普检检测报告", type = LogType.INSERT)
    @Override
    @RequestMapping(method = RequestMethod.POST)
    public Long insert(RestJsonWrapperBean wrapper) {
        return getService().insert(wrapper);
    }

    @Override
    public void createReports(String ids) {
        getService().createReports(ids);
    }

    @Override
    public void previewOnlineReports(String ids, HttpServletRequest request, HttpServletResponse response) {
        getService().previewReport(ids,response);
    }

    @Override
    public String downloadReports(String ids, HttpServletRequest request, HttpServletResponse response) {
        return getService().downloadReports(ids, response);
    }

    @ValidateDataWith(LimsReportSubmitValidator.class)
    @Override
    public void startProcess(RestJsonWrapperBean wrapper) {
        getService().startProcess(wrapper);
    }

    @Override
    public String reportsGroupMergeDownload(String ids, String type, HttpServletRequest request, HttpServletResponse response) {
        return getService().reportsGroupMergeDownload(ids, type, response);
    }
}
